package cn.imvc.app.controllers.member;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import cn.imvc.app.domains.FundFlowType;
import cn.imvc.app.entities.FundFlow;
import cn.imvc.app.models.FundFlowModel;
import cn.imvc.data.domain.ViewRequest;

/**
 * 
 * @author wujx
 * @time 2016年8月11日
 *
 */
public class FundFlowControllerImpl implements FundFlowController {
	public Page<FundFlow> page;
	public ViewRequest viewRequest;
	@Autowired
	private FundFlowModel fundFlowModel;
	private Map<Byte,String> fundFlowType = FundFlowType.elMap;
	private int id;
	public String search() {
		// TODO Auto-generated method stub
		return null;
	}
	public String index() {
		if(viewRequest == null){
			viewRequest = new ViewRequest();
		}
		viewRequest.getSort().put("createdAt", "DESC");
		
		String geMoney = viewRequest.getParams().get("_and_f_dot_money_ge_number");
		if(geMoney != null && !geMoney.equals("")){
			viewRequest.getParams().put("_and_f_dot_money_ge_number",Float.parseFloat(geMoney)*100+"");
		}
		String leMoney = viewRequest.getParams().get("_and_f_dot_money_le_number");
		if(leMoney != null && !leMoney.equals("")){
			viewRequest.getParams().put("_and_f_dot_money_le_number",Float.parseFloat(leMoney)*100+"");
		}
		
		page = fundFlowModel.findAll(viewRequest);
		return "fund-flow/index";
	}
	/**
	 * 显示某位会员的资金流水
	 */
	public String show() {
		page = fundFlowModel.findAllByMemberId(viewRequest,id);
		return "fund-flow/dialog";
	}
	public String editNew() {
		// TODO Auto-generated method stub
		return null;
	}
	public String create() {
		// TODO Auto-generated method stub
		return null;
	}
	public String edit() {
		// TODO Auto-generated method stub
		return null;
	}
	public String update() {
		// TODO Auto-generated method stub
		return null;
	}
	public String destroy() {
		// TODO Auto-generated method stub
		return null;
	}
	public String destroyBatch() {
		// TODO Auto-generated method stub
		return null;
	}
	public ViewRequest getViewRequest() {
		return viewRequest;
	}
	public void setViewRequest(ViewRequest viewRequest) {
		this.viewRequest = viewRequest;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public void setPage(Page<FundFlow> page) {
		this.page = page;
	}
	public Page<FundFlow> getPage() {
		return page;
	}
	public Map<Byte, String> getFundFlowType() {
		return fundFlowType;
	}
	public void setFundFlowType(Map<Byte, String> fundFlowType) {
		this.fundFlowType = fundFlowType;
	}
}
